import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import postcssImport from 'postcss-import'

import autoprefixer from 'autoprefixer'
import postCssPxToRem from "postcss-pxtorem";


// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    proxy: {
      '/ws': {
        target: 'ws://localhost:8080',
        ws: true,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/ws/, '')
      }
    }
  },
  css: {
    postcss: {
      plugins: [
        postcssImport,
        // tailwindcss,
        autoprefixer,
        postCssPxToRem({
          rootValue: 75, // 根据设计稿宽度计算，这里假设设计稿宽度为750px，1rem = 75px/100px
          propList: ['*'], // 需要转换的属性，*表示所有属性
          selectorBlackList: [], // 忽略的选择器
          replace: true,
          mediaQuery: false,
          minPixelValue: 0,
          exclude: /node_modules/i // 忽略包文件转换rem
        })
      ]
    }
  }
})
